# coding:utf-8
import time

from sqlalchemy.orm import sessionmaker
from sqlalchemy import create_engine
from sql_foreign_models import *

# 修改用户名、密码和数据库的名称为自己的
engine = create_engine("sqlite:///test.db")
Session_class = sessionmaker(bind=engine)
session = Session_class()

while(1):
    # 查询phone表
    phone_obj = session.query(Phone).filter_by(id=1).first()
    # 通过phone表关联的relationship字段"Company"查询出company表的数据
    print(phone_obj.company.name)
    print(phone_obj.company.location)
    time.sleep(0.5)


